package com.emser.unc.server.domain;


import java.util.Date;
import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Sequence;
import javax.jdo.annotations.SequenceStrategy;

import com.emser.unc.serializable.SaleReportDTO;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Sequence(name = "seqSR", strategy = SequenceStrategy.NONTRANSACTIONAL,extensions = @Extension(vendorName = "datanucleus", key="key-cache-size", value="12"))
public class SaleReport {
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	private Key key;
	@Persistent
	private Long id;
	@Persistent
	private Date date;
	@Persistent
	private String sellerUserName;
	@Persistent
	private Long customerID;
	@Persistent
	private Double amount;
	@Persistent
	private UserAccount userA;
	@Persistent
	private String userAName;
	
	public Long getId() {
		return id;
	}
	public void setId() {
		this.id = key.getId();
	}
	public String getSellerUserName() {
		return sellerUserName;
	}
	public void setSellerName(String sellerUserName) {
		this.sellerUserName = sellerUserName;
	}
	public Long getCustomerID() {
		return customerID;
	}
	public void setCustomerID(Long customerID) {
		this.customerID = customerID;
	}
	public Double getTotal() {
		return amount;
	}
	public void setTotal(Double total) {
		this.amount = total;
	}
	public Key getKey() {
		return key;
	}
	
	public static SaleReportDTO toDTO(SaleReport saleReport) {
	    if (saleReport == null) {
	      return null;
	    }
	    SaleReportDTO saleReportDTO = new SaleReportDTO();
	    saleReportDTO.setIdReport(saleReport.getId());
	    saleReportDTO.setDate(saleReport.getDate());
	    saleReportDTO.setAmount(saleReport.getTotal());
	    saleReportDTO.setCustomerID(saleReport.getCustomerID());
	    saleReportDTO.setSellerUserName(saleReport.getSellerUserName());
	    return saleReportDTO;
	}
	public UserAccount getUserA() {
		return userA;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Date getDate() {
		return date;
	}
	public void setUserAName(String userAName) {
		this.userAName = userAName;
	}
	public String getUserAName() {
		return userAName;
	}

}
